import { ApiProperty } from '@nestjs/swagger';
import { PartialType } from '@nestjs/swagger';
import { Decorator_DtoIsNumber_Base } from '@/common/decorators/dtoIsNumber';

import { IsBoolean, IsNotEmpty, IsOptional, IsString } from 'class-validator';

export class Menu_Create_Dto {
  @IsString()
  @IsNotEmpty()
  @ApiProperty({ description: '名称' })
  menuName: string;

  @IsBoolean()
  @IsOptional()
  @ApiProperty({ default: false, description: '是否属于菜单' })
  isMenu?: boolean;

  @IsString()
  @IsNotEmpty()
  @ApiProperty({ description: '菜单键/权限键' })
  menuKey: string;

  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  @ApiProperty({ default: 0, description: '排序' })
  menuOrder?: number;

  @IsBoolean()
  @IsOptional()
  @ApiProperty({ default: true, description: '是否禁用' })
  canUse?: boolean;

  @IsBoolean()
  @IsOptional()
  @ApiProperty({ description: '是否缓存菜单' })
  keepAlived?: boolean;

  @IsString()
  @IsOptional()
  @ApiProperty({ description: '组件路径' })
  componentPath?: string;

  @IsString()
  @IsOptional()
  @ApiProperty({ description: '菜单图标' })
  menuIcon?: string;

  @IsString()
  @IsOptional()
  @ApiProperty({ description: '菜单类型' })
  isExpandMenu?: string;

  @IsString()
  @IsOptional()
  @ApiProperty({ description: '菜单图片' })
  menuImg?: string;

  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  @ApiProperty({ description: '父级ID' })
  parentId?: number;
}

export class Menu_Find_Dto {
  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  size?: number;

  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  page?: number;

  @IsString()
  @IsOptional()
  @ApiProperty({ description: '名称' })
  menuName?: string;
}

export class Menu_Update_Dto extends PartialType(Menu_Create_Dto) {
  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  id: number;
}
